/*
 * @Author: HuangBingQuan <17671241237@163.com>
 * @Date: 2024-03-08 22:44:24
 * @LastEditTime: 2024-03-14 20:46:42
 * @FilePath: /san-zi-qi/src/components/ChessComp/ChessComp.tsx
 */

import { ChessType } from "../../type/enums";
import "./ChessComp.scss";

interface IProps {
    type: ChessType,
    onClick?: ()=> void
}

export const ChessComp = (props: IProps)=> {
    let chess = null;
    if(props.type === ChessType.red) {
        chess = <div className="red chess-item"></div>
    }else if(props.type === ChessType.black) {
        chess = <div className="black chess-item"></div>
    }
    return (
        <div className="chess" onClick={()=> {
            if(props.type === ChessType.none && props.onClick) {
                props.onClick()
            }
        }}>
            { chess }
        </div>
    )
}
